objectmapper in java 8

95

objectmapper in java 8 -

public static <T> List<T> mapPayloadListToPOJOList(List<String> payloadList, Class<T> pojo) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    List<T> pojoList = new ArrayList<>();
    for (String payload : payloadList) {
        T mapped = mapper.readValue(payload, pojo);
        pojoList.add(mapped);
    }
    return pojoList;
}

Comments

Submit
0 Comments